#include "MyRectangle.h"
MyRectangle::MyRectangle(int x, int y , int w , int h )
{
	this ->sdlRect.x = x ;
	this ->sdlRect.y = y ;
	this ->sdlRect.w = w ;
	this ->sdlRect.h = h ;
}
bool MyRectangle::contain(int x, int y)
{
	int x1 = this ->sdlRect.x + this ->sdlRect.w ;
	int y1 = this ->sdlRect.y + this ->sdlRect.h;

	return ((x > this ->sdlRect.x ) && ( x < x1 )) &&  
		   (( y >this ->sdlRect.y) && (y < y1) );   
}
bool MyRectangle:: collision(const MyRectangle &rect)
{
	int x1 = rect.sdlRect.x ;
	int y1 = rect.sdlRect.y ;

	int x2 = rect.sdlRect.x + rect.sdlRect.w;
	int y2 = rect.sdlRect.y ;

	int x3 = rect.sdlRect.x ;
	int y3 = rect.sdlRect.y + rect.sdlRect.h;

	int x4 = rect.sdlRect.x + rect.sdlRect.w ;
	int y4 = rect.sdlRect.y + rect.sdlRect.h ;

	return contain(x1,y1) || contain(x2,y2) || contain(x3,y3) || contain(x4,y4) ;

}